import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import electron from "vite-plugin-electron"
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import {resolve} from 'path'
import autoprefixer from 'autoprefixer'
import pxtorem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [vue(),electron({
    main: {
      entry: "electron/index.ts"
    },
    preload: {
      input: "electron/preload.ts"
    }
  }), AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
    Components({
      resolvers: [ElementPlusResolver()],
    })],
    css: {
      postcss: {
        plugins: [
          autoprefixer({
            overrideBrowserslist: [
              'Android 4.1',
              'iOS 7.1',
              'Chrome > 31',
              'not ie <= 11',
              'ff >= 30',
              '> 1%',
              'last 2 versions',
            ],
            grid: true,
          }),
          pxtorem({
            rootValue: 192,
            unitPrecision: 2,
            selectorBlackList: ['.no-rem', 'no-rem'],
            propList: ['*'],
            replace: true,
            mediaQuery: false,
            minPixelValue: 0,
          }),
        ],
      },
    },
    resolve: {
      alias: {
       '@': resolve(__dirname,"./src")
     }
   }
})

// vue 启动项
// export default defineConfig({
//   base: "./",
//   plugins: [vue(),
//     AutoImport({
//       resolvers: [ElementPlusResolver()],
//     }),
//     Components({
//       resolvers: [ElementPlusResolver()],
//     })],
//   resolve: {
//     alias: {
//       '@': resolve(__dirname,"./src")
//     }
//   }
// })
